package org.nmgyjt.springboot.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nmgyjt.springboot.entity.admin.CsSystemSourceExt;
import org.nmgyjt.springboot.entity.rescueTeam.RescueTeam;
import org.nmgyjt.springboot.mapper.CsSystemSourceExtMapper;
import org.nmgyjt.springboot.service.ICsSystemSourceExtService;
import org.nmgyjt.springboot.utils.ZWWXUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author [mybatis plus generator]
 * @since 2023-07-12
 */
@Service
public class CsSystemSourceExtServiceImpl extends ServiceImpl<CsSystemSourceExtMapper, CsSystemSourceExt> implements ICsSystemSourceExtService {
    @Autowired
    CsSystemSourceExtMapper csSystemSourceExtMapper;
    @Autowired
    ZWWXUtils zwwxUtils;
    @Override
    public void snycZwwxByHeadPhone() {
        List<Map<String,String>> list=csSystemSourceExtMapper.findExtList();
        for(Map<String,String> map:list){
            String id=map.get("id");
            String menuId=map.get("menuId");
            String phone=map.get("phone");
            String orgId=map.get("orgId");
            if("1000000010".equals(menuId)){
                String ssoAccessToken=zwwxUtils.getGovWxToken();
                Integer code=zwwxUtils.getZWUserInfo(phone,"rescue/rescue-detail?depId="+orgId,ssoAccessToken);
                CsSystemSourceExt ext=new CsSystemSourceExt();
                ext.setId(id);
                ext.setSnycState(code.toString());
                this.saveOrUpdate(ext);
            }
            if("1000000011".equals(menuId)){
                String ssoAccessToken=zwwxUtils.getGovWxToken();
                Integer code=zwwxUtils.getZWUserInfo(phone,"supplies/supplies-detail?depId="+orgId,ssoAccessToken);
                CsSystemSourceExt ext=new CsSystemSourceExt();
                ext.setId(id);
                ext.setSnycState(code.toString());
                this.saveOrUpdate(ext);
            }
            if("1000000012".equals(menuId)){
                String ssoAccessToken=zwwxUtils.getGovWxToken();
                Integer code=zwwxUtils.getZWUserInfo(phone,"protect-unit-detail/index?depId="+orgId,ssoAccessToken);
                CsSystemSourceExt ext=new CsSystemSourceExt();
                ext.setId(id);
                ext.setSnycState(code.toString());
                this.saveOrUpdate(ext);
            }
            if("1000000014".equals(menuId)){
                String ssoAccessToken=zwwxUtils.getGovWxToken();
                Integer code=zwwxUtils.getZWUserInfo(phone,"refuge-detail/index?depId="+orgId,ssoAccessToken);
                CsSystemSourceExt ext=new CsSystemSourceExt();
                ext.setId(id);
                ext.setSnycState(code.toString());
                this.saveOrUpdate(ext);
            }
        }
    }
}
